package tq.com.tqteacher.mine.model;

import com.helper.StringHelper;

import org.json.JSONObject;

import tq.com.tqcom.recyclerAdapter.declear.IRecyclerItem;
import tq.com.tqcom.recyclerAdapter.declear.IRecyclerSection;

public class TQBuyInfoSection extends IRecyclerSection {

    static public int VIEW_TYPE_YEAR = 0x01;
    static public int VIEW_TYPE_MONTH = 0x00;

    public void setHeader(TQBuyInfoItem pHeader){
        headerItem = pHeader;
    }


    static public class TQBuyInfoItem extends IRecyclerItem{
        private String year;

        private String month;
        private int count;
        private boolean isLeft;

        public void fromJson(JSONObject pObject){
            if(pObject == null)return;

            setType(VIEW_TYPE_MONTH);
            month = pObject.optString("month");
            count = pObject.optInt("count");
        }

        public boolean isLeft(){
            return isLeft;
        }
        public void  setLeft(boolean pIsLeft){
            isLeft = pIsLeft;
        }

        public boolean isYear(){
            return !StringHelper.isEmpty(year);
        }
        public String getYear() {
            return year;
        }

        public void setYear(String pYear) {
            year = pYear;
            setType(VIEW_TYPE_YEAR);
        }

        public String getMonth() {
            return month;
        }

        public void setMonth(String pMonth) {
            month = pMonth;
        }

        public int getCount() {
            return count;
        }

        public void setCount(int pCount) {
            count = pCount;
        }
    }
}
